package com.jsf.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jsf.entity.SaleChance;
import com.jsf.entity.SalePlan;
import com.jsf.service.ISaleChanceService;
import com.jsf.service.ISalePlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jsf
 * @since 2022-02-21
 */
@RestController
@RequestMapping("/salePlan")
public class SalePlanController {
    @Autowired
    private ISalePlanService ss;
    @GetMapping("/selectAll")
    public List<SalePlan> selectAll(){
        return ss.list();
    }

    @GetMapping("/selectByCid/{cid}")
    public List<SalePlan> selectByCid(@PathVariable("cid")int cid){
        QueryWrapper<SalePlan> wrapper=new QueryWrapper<>();
        wrapper.eq("sid",cid);
        return ss.list(wrapper);
    }

    @PostMapping("/add")
    public void add(@RequestBody SalePlan salePlan){
        ss.save(salePlan);
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") int id){
        ss.removeById(id);
    }
}

